<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>

                    <p:panel header="Unit Issue Report" >



                        <h:panelGrid columns="2">
                            <h:outputLabel value="Issue Department" ></h:outputLabel>
                            <p:autoComplete completeMethod="#{departmentController.completeDept}" var="dept" 
                                            itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" 
                                            value="#{storeReportsTransfer.department}" converter="departmentConverter" >
                            </p:autoComplete>
                            <h:outputLabel value="From" />
                            <p:calendar value="#{storeReportsTransfer.fromDate}" pattern="dd MMMM yyyy HH:mm:ss" ></p:calendar>
                            <h:outputLabel value="To" />
                            <p:calendar value="#{storeReportsTransfer.toDate}" pattern="dd MMMM yyyy HH:mm:ss" ></p:calendar>



                        </h:panelGrid>
                        <h:panelGroup >
                            
                            <p:commandButton ajax="false" value="Fill" action="#{storeReportsTransfer.createDepartmentIssueStore}" ></p:commandButton>

                            <p:commandButton value="Print" ajax="false" action="#" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>

                            <p:commandButton ajax="false" value="Excel" style="float: right;" >
                                <pe:exporter type="xlsx" target="tbl" fileName="Unit_Issue_Report_by_department"  />
                            </p:commandButton> 
                        </h:panelGroup> 


                        <h:panelGroup id="gpBillPreview">
                            <p:dataTable id="tbl" styleClass="noBorder normalFont" value="#{storeReportsTransfer.listz}" var="i"  >
                                <f:facet name="header">
                                    <h:outputLabel value="Unit Issue From "/>
                                    <h:outputLabel value="#{storeReportsTransfer.department.name}" rendered="#{storeReportsTransfer.department ne null}"/>
                                    <h:outputLabel value="#{sessionController.department.name}" rendered="#{storeReportsTransfer.department eq null}"/>
                                    <h:outputLabel value="From : " style=" white-space:pre-line;"/>
                                    <h:outputLabel value="#{storeReportsTransfer.fromDate}">
                                        <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a" ></f:convertDateTime>
                                    </h:outputLabel>
                                    <h:outputLabel value="&emsp;&emsp;To : "/>
                                    <h:outputLabel value="#{storeReportsTransfer.toDate}">
                                        <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a" ></f:convertDateTime>
                                    </h:outputLabel>
                                </f:facet>

                                <p:column headerText="Department">
                                    <f:facet name="header">
                                        <h:outputLabel value="Department"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.string}" ></h:outputLabel>                                    
                                </p:column>

                                <p:column headerText="Net Total" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Net Total"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.value1}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{storeReportsTransfer.netTotalValues}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>  
                                </p:column>
                                <f:facet name="footer" >
                                    <h:outputLabel value="Printed By : #{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                                </f:facet>
                            </p:dataTable>


                        </h:panelGroup>
                    </p:panel>
                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
